#include <iostream>
#include <vector>
using namespace std;
void repeatCombination(vector<int> arr, vector<int> comb, vector<vector<int>>& ret, int r, int index, int depth){
if(r==0){
ret.push_back(comb);
} else if(depth==arr.size()) return;
else {
comb[index]=arr[depth];
repeatCombination(arr, comb, ret, r-1, index+1, depth);
repeatCombination(arr, comb, ret, r, index, depth+1);
}
}
int main(void){
vector<int> vec={1, 2, 3, 4};
int r=3;
vector<int> comb(r);
vector<vector<int>> ret;
repeatCombination(vec, comb, ret, r, 0, 0);
for(vector<int> tmp_vec: ret){
for(int tmp_int: tmp_vec) cout<<tmp_int<<" ";
cout<<endl;
}
return 0;
}